<%@ page contentType="text/html; charset=utf-8" %>
<%@ include file="/WEB-INF/jsp/com/include/declare.jspf" %>
<%@ include file="/WEB-INF/jsp/com/include/doctype.jspf" %>
<script type="text/javascript" src="/kr/common/js/pie/pie_ready.js"></script>
<script>
function tdaDetailView(viewNo){
    
    var tsrdPrctNo = document.getElementById("tsrdPrctNo");
    tsrdPrctNo.value= viewNo;

    var frm = document.summeryForm;
     frm.action="<c:url value='/mpg/mpgTdaDetailInfo.do'/>";
    frm.submit();
        
}

function qaDetailView(qaSn){
    
    var qaSn1 = document.getElementById("qaSn");
    
    qaSn1.value = qaSn;
   
    var form = document.summeryForm;
    form.action = "<c:url value='/mpg/QAAswInfo.do'/>";
    form.submit();    
}


function openLayer1(evntMnSn){
    $.ajax({
        type: "GET",
        dataType : "text",
        url: "<c:url value='/evnt/evntWnrLayer.do'/>",
        data: { 
            'evntMnSn' : evntMnSn
        },
        success: function(data){
            if(data){
                $("#layerpopup-winnerpopup").html('');
                $("#layerpopup-winnerpopup").append(data);
                $('body').dimmedFrame();
                var wHeight = $(window).height();
                var divHeight = $("#winnerpopup").height(); 
                $("#winnerpopup").css({top:$(window).scrollTop()+((wHeight - divHeight) /2)}).show();
            }
        }
    });
    
}

function closeLayer1(){
    $('.dimmed-frame').remove();
    $("#winnerpopup").hide(); 
}

function checkWinner(evntMnSn){

    var hpNo1 = $("#hpNo1");
    var hpNo2 = $("#hpNo2");
    var hpNo3 = $("#hpNo3");
    var mbrNm = $("#mbrNm");
    
    if(hpNo2.val() == "" || hpNo2.val().length<3){
        alert("전화번호를 입력해 주세요.");
        hpNo2.focus();
        return;
    }
    if(hpNo3.val() == "" || hpNo3.val().length<4){
        alert("전화번호를 입력해 주세요.");
        hpNo3.focus();
        return;
    }
    
    if(mbrNm.val() == ""){
        alert("성명을 입력해 주세요.");
        mbrNm.focus();
        return;
    }
    var ptcChidHpNo = hpNo1.val()+hpNo2.val()+hpNo3.val();
    var ptcChidNm = mbrNm.val();
    
    
    $.ajax({
        type: "POST",
        dataType : "xml",
        url: "<c:url value='/evnt/selectEvntWnrDetail.do'/>",
        data: { 
            'evntMnSn' : evntMnSn,
            'ptcChidHpNo' : ptcChidHpNo,
            'ptcChidNm' : ptcChidNm
        },
        success: function(data){
            var result={};
            var items = $(data).find("item");
            items.each(function(index,element){
               var name = $(this).find("name").text();
               var value = $(this).find("value").text();
               result[name] = value;
            });
            if(result["result"] =="OK"){
                $.ajax({
                    type: "POST",
                    dataType : "text",
                    url: "<c:url value='/evnt/evntWnrMemoLayer.do'/>",
                    data: { 
                        'evntMnSn' : evntMnSn,
                        'winCd' : result["value"]
                    },
                    success: function(data){
                        if(data){
                            $("#layerpopup-winnerpopup").html('');
                            $("#layerpopup-winnerpopup").append(data);
                            $('body').dimmedFrame();
                            $("#winnerpopup").hide();
                            $("#layerpopup-winnerpopup2").html('');
                            $("#layerpopup-winnerpopup2").append(data);
                            var wHeight = $(window).height();
                            var divHeight = $("#winnerpopup02").height();
                            if(divHeight > wHeight){
                                $("#winnerpopup02").css({top:$(window).scrollTop()});    
                            }else{
                                $("#winnerpopup02").css({top:$(window).scrollTop()+((wHeight - divHeight) /2)});
                            }
                            
                            $("#winnerpopup02").show();
                        }
                    }
                });
            }else{
                $.ajax({ 
                    type: "POST",
                    dataType : "text",
                    url: "<c:url value='/evnt/evntFailLayer.do'/>",
                    data: { 
                        'evntMnSn' : evntMnSn 
                    },
                    success: function(data){
                        if(data){
                            $("#layerpopup-winnerpopup").html('');
                            $("#layerpopup-winnerpopup").append(data);
                            $('body').dimmedFrame();
                            $("#winnerpopup").hide();
                            $("#layerpopup-winnerpopup2").html('');
                            $("#layerpopup-winnerpopup2").append(data);
                            var wHeight = $(window).height();
                            var divHeight = $("#winnerpopup02").height();
                            if(divHeight > wHeight){
                                $("#winnerpopup02").css({top:$(window).scrollTop()});    
                            }else{
                                $("#winnerpopup02").css({top:$(window).scrollTop()+((wHeight - divHeight) /2)});
                            }                            
                            $("#winnerpopup02").show();
                        }
                    }
                });  
            }
        }
    });
    
}

function evntPrint(id) {
    $('#'+id).printArea({mode: 'popup', popupClose: false});
}

function goView(st, seq){
    if(st=="P"){
        location.href="/kr/evnt/selectEvntMnDetail.do?evntMnSn="+seq;
    }else if(st=="S"){
        location.href="/kr/evnt/selectEvntMnDetailEnd.do?evntMnSn="+seq;
    }
}

</script>
</head>
<body>
<!-- 당첨자 발표 -->
<div id="winnerpopup" class="layerpopup winnerpopup"><div class="layerpopup-inner">
    <div class="layerpopup-head">
        <h1><img src="/kr/images/layerpopup/h1_winner.gif" alt="당첨자 발표" /></h1>
        <p class="desc"><img src="/kr/images/layerpopup/h1_winner_desc.gif" alt="이벤트에 참여해주신 모든 고객님들께 감사 드립니다." /></p>
    </div>
    <div class="layerpopup-contents" id="layerpopup-winnerpopup">
        
    </div>
    <!-- close -->
    <div class="close-area"><div class="close-area-inner">
        <img src="/kr/images/layerpopup/btn_close.gif" alt="닫기" class="close" />
    </div></div>
    <!-- //close -->
</div></div>
<!-- //당첨자 발표 -->

<!-- 당첨자 발표2 -->
<div id="winnerpopup02" class="layerpopup winnerpopup02"><div class="layerpopup-inner">
    <div class="layerpopup-head">
        <h1><img src="/kr/images/layerpopup/h1_winner.gif" alt="당첨자 발표" /></h1>
        <p class="desc"><img src="/kr/images/layerpopup/h1_winner_desc.gif" alt="이벤트에 참여해주신 모든 고객님들께 감사 드립니다." /></p>
    </div>
    <div class="layerpopup-contents" id="layerpopup-winnerpopup2">
        
    </div>
    <!-- close -->
    <div class="close-area"><div class="close-area-inner">
        <img src="/kr/images/layerpopup/btn_close.gif" alt="닫기" class="close" />
    </div></div>
    <!-- //close -->
</div></div>  
<!-- //당첨자 발표2 --> 
<%@ include file="/WEB-INF/jsp/com/include/layerpopup.jspf" %>
<div id="wrap" class="non-subnavigation">
    <%@ include file="/WEB-INF/jsp/com/include/navi_utill_sub.jspf" %>
    <%@ include file="/WEB-INF/jsp/com/include/navi_header.jspf" %>
    <hr />

    <%@ include file="/WEB-INF/jsp/com/include/sub_header_global03.jspf" %>
    <hr />


	<div id="container">
		<div id="subtitle-area"><div class="subtitle-area-inner">
			<%@ include file="/WEB-INF/jsp/com/include/location.jspf" %>
		</div></div>
		<div id="article">
            <form name="summeryForm" id="summeryForm" onsubmit="return false">
            <input type="hidden" name="tsrdPrctNo" id="tsrdPrctNo" value="<c:out value="${mpgSearchInfoVO.tsrdPrctNo }"/>">
            <input type="hidden" name="qaSn" id="qaSn">
            <input type="hidden" id="totalRow" name="totalRow" value="<c:out value="${mpgSearchInfoVO.total}"/>">
            <input type="hidden"  id="pageIndex" name="pageIndex" value ="<c:out value="${mpgSearchInfoVO.pageIndex}"/>">
            <input type="hidden" id="mbrSn"  name="mbrSn" value="<c:out value="${mpgSearchInfoVO.mbrSn }"/>" >

			<ul class="mypage-navigation">
				<li><a href="<c:url value="/mpg/summeryList.do"/>"><img src="/kr/images/global_menu/navi_mypage01_over.gif" alt="나의 요약정보" /></a></li>
				<li><a href="<c:url value="/mpg/pwdCheckView.do"/>"><img src="/kr/images/global_menu/navi_mypage02_out.gif" alt="회원 정보" /></a></li>
				<li><a href="<c:url value="/mpg/QuotList.do"/>"><img src="/kr/images/global_menu/navi_mypage03_out.gif" alt="최근 견적" /></a></li>
				<li><a href="<c:url value="/mpg/ctlgListPaging.do"/>"><img src="/kr/images/global_menu/navi_mypage04_out.gif" alt="카탈로그 신청 이력" /></a></li>
				<li><a href="<c:url value="/mpg/tdaListPaging.do"/>"><img src="/kr/images/global_menu/navi_mypage05_out.gif" alt="시승 신청 이력" /></a></li>
				<li><a href="<c:url value="/mpg/mpgEvntInfoView.do"/>"><img src="/kr/images/global_menu/navi_mypage06_out.gif" alt="이벤트 참여 이력" /></a></li>
				<li><a href="<c:url value="/mpg/QAListPaging.do"/>"><img src="/kr/images/global_menu/navi_mypage07_out.gif" alt="Q&amp;A" /></a></li>
			</ul>
			<h4 class="subsection"><img src="/kr/images/title/h4_global_menu03_01.gif" alt="나의 요약정보" /></h4>
			<div class="summary-my-status">
				<p class="user-name">
					<strong><c:out value="${mbrInfoVO.mbrNm}"/></strong>
					<img src="/kr/images/global_menu/txt_global_menu03_01_01.png" alt="님의 방문을 환영합니다" />
				</p>
				<p class="recent-visit">
					<img src="/kr/images/global_menu/txt_global_menu03_01_02.gif" alt="최근방문일" class="d-tit" />
                    ${fn:substring(mbrInfoVO.lstLoginDtm, 0, 4)}년${fn:substring(mbrInfoVO.lstLoginDtm, 4, 6)}월${fn:substring(mbrInfoVO.lstLoginDtm, 6, 8)} 일


				</p>
				<div class="address"><div class="address-inner">
					<img src="/kr/images/global_menu/txt_global_menu03_01_03.gif" alt="주소" class="d-tit" />
					<c:out value="${mbrInfoVO.adr }"/><c:out value="${mbrInfoVO.dtlAdr}"/>
					<a href="<c:url value="/mpg/pwdCheckView.do"/>"><img src="/kr/images/common/button/btn_personifo_modify.gif" alt="개인정보 수정하기" class="modify" /></a>
				</div></div>
			</div>

			<div class="summary-contents-wrap subsection">
				<h5><img src="/kr/images/title/h5_global_menu03_01_01.gif" alt="최근 견적" /></h5>
				<div class="recent-estimation">
                      <c:if test="${empty quotList }">
                        <li>
                                                                       견적 정보가 없습니다.
                        </li>
                    </c:if>               
                 <c:forEach var="result" items="${ quotList }" varStatus="status">
                
                   <c:if test ='${status.index lt 2  }' >
					<div class="cell">
						<p class="car-name"><a href="<c:url value="/mpg/quotDetailView.do?quotNo=${result.quotNo }"/>"><span style="text-decoration underline;color:white;"><c:out value="${result.carName }"/><c:out value="${result.gradeName }"/></span></a></p>
						<div class="car-spec-wrap">
							<div class="car-spec">
								<ul>
									<li>
										<img src="/kr/images/global_menu/txt_global_menu03_01_04.gif" alt="색상" class="d-tit" />
										<c:out value="${result.colorName }"/>
									</li>
									<li>
										<img src="/kr/images/global_menu/txt_global_menu03_01_05.gif" alt="가격" class="d-tit" />
										<c:out value="${result.carPrice }"/>원
									</li>
								</ul>
								<a href="<c:url value="/pur/purMgmtFrontView.do"/>"><img src="/kr/images/common/button/btn_purchase_counsel03.gif" alt="구매상담 신청" /></a>
							</div>
							<img src="<c:out value="${result.imagePath }"/>" alt="차량이미지" class="car-thumb" />
						</div>
					</div>
                    </c:if>
                    </c:forEach>

				</div>
				<a href="<c:url value="/mpg/QuotList.do"/>"><img src="/kr/images/common/button/btn_more.gif" alt="더보기" class="more" /></a>
			</div>
			<div class="summary-contents-wrap subsection">
				<h5><img src="/kr/images/title/h5_global_menu03_01_02.gif" alt="카탈로그 신청 이력" /></h5>
				<div class="boardlist-wrap02">
					<table summary="번호, 신청내용, 신청일자, 상태">
					<caption>카탈로그 신청 이력</caption>
					<colgroup>
						<col width="10%" />
						<col />
						<col width="20%" />
						<col width="15%" />
					</colgroup>
					<thead>
                    <tr>
                        <th scope="col">NO</th>
                        <th scope="col">신청내용</th>
                        <th scope="col">신청일자</th>
                        <th scope="col">상태</th>
                    </tr>
                    </thead>                
                    <tbody>
                      <c:if test="${empty ctlgList }">
                        <tr>
                        <td colspan="4">  신청 이력이 없습니다.</td>
                        </tr>
                    </c:if>                   
                    <c:forEach var="result" items="${ ctlgList }" varStatus="status">
                      <c:if test ='${status.index lt 3  }' >
					<tr>
						<td class="center"><c:out value="${result.rnum }"/></td>
						<td>우편신청 (<c:out value="${result.carName }"/>)</td>
						<td class="center"><c:out value="${result.rgstDttm }"/></td>
						<td class="center last"><c:out value="${result.sttsNm }"/></td>
					</tr>
                    </c:if>
                    </c:forEach>
					</tbody>
					</table>
				</div>
				<a href="<c:url value="/mpg/ctlgListPaging.do"/>"><img src="/kr/images/common/button/btn_more.gif" alt="더보기" class="more" /></a>
			</div>
			<div class="summary-contents-wrap subsection">
				<h5><img src="/kr/images/title/h5_global_menu03_01_03.gif" alt="시승 신청 이력" /></h5>
				<div class="boardlist-wrap02">
					<table summary="예약구분, 시승차량, 시승센터, 시승일시, 시승요청위치, 예약상태">
					<caption>시승 신청 이력</caption>
					<colgroup>
						<col width="20%" />
						<col />
						<col width="13%" />
						<col width="13%" />
						<col width="10%" />
						<col width="8%" />
					</colgroup>
					<thead>
					<tr>
						<th scope="col">예약구분</th>
						<th scope="col">시승차량</th>
						<th scope="col">시승센터</th>
						<th scope="col">시승일시</th>
						<th scope="col">시승요청위치</th>
						<th scope="col">예약상태</th>
					</tr>
					</thead>
					<tbody>
                     <c:if test="${empty tdaList }">
                        
                     <tr><td colspan="6">신청 이력이 없습니다.</td></tr>
                       
                    </c:if>
                    <c:forEach var="result" items="${ tdaList }" varStatus="status">
                      <c:if test ='${status.index  lt 3  }' >
					<tr>
						<td><c:out value="${result.tsrdSvcNm}"/></td>
						<td class="center"><a href="javascript:tdaDetailView(${result.tsrdPrctNo})"><c:out value="${result.carDtlInfo}"/> / <c:out value="${result.carXrclCtyNm }"/></a></td>
                        <td class="center"><c:out value="${result.ctrNm }"/></td>
                        <td class="center"><c:out value="${result.tsrdDt}"/></td>
                        <td class="center"><c:out value="${result.sbcrAddr1}"/> <c:out value="${result.sbcrAddr2 }"/></td>
                        <td class="center last"><c:out value="${result.prctStNm }"/></td>
					</tr>
                    </c:if>
                    </c:forEach>
					</tbody>
					</table>
				</div>
				<a href="<c:url value="/mpg/tdaListPaging.do"/>"><img src="/kr/images/common/button/btn_more.gif" alt="더보기" class="more" /></a>
			</div>
			<div class="summary-contents-wrap subsection">
				<h5><img src="/kr/images/title/h5_global_menu03_01_04.gif" alt="이벤트 참여 이력" /></h5>
				<div class="event-list">
                <jsp:useBean id="now" class="java.util.Date"/> 
                <fmt:formatDate value="${now}" pattern="yyyyMMddHHmm"  var="now0"/>  
                    <c:if test="${empty evntList }">
                        <li>
                                                                       참여  이력이 없습니다.
                        </li>
                    </c:if>
                    <c:forEach var="result" items="${ evntList }" varStatus="status">
                    
                      <c:if test ='${status.index lt 2  }' >
                    <fmt:parseDate value="${result.fnhDt}" pattern="yyyyMMddHHmm" var="now1" /> 
                    <fmt:formatDate value="${now1}" pattern="yyyyMMddHHmm"  var="now2"/> 
					<div class="section">
						<img src="<c:url value='${result.thumnImgPath}'/>" alt="${result.evntTitl}" class="thumb" />
						<ul class="information">
							<li>
								<strong class="title"><img src="/kr/images/event/txt_event01_02.gif" alt="제목" /></strong>
								<p class="subject"><a href="#"><c:out value="${result.evntTitl}"/></a></p>
							</li>
							<li>
								<strong class="title"><img src="/kr/images/event/txt_event01_03.gif" alt="내용" /></strong>
								<p><c:out value="${result.evntSbc}"/></p>
							</li>
							<li>
								<strong class="title"><img src="/kr/images/event/txt_event01_04.gif" alt="기간" /></strong>
								<p>${fn:substring(result.strtDt, 0, 4)}-${fn:substring(result.strtDt, 4, 6)}-${fn:substring(result.strtDt, 6, 8)} ~ ${fn:substring(result.fnhDt, 0, 4)}-${fn:substring(result.fnhDt, 4, 6)}-${fn:substring(result.fnhDt, 6, 8)}</p>
							</li>
							<li>
								<strong class="title"><img src="/kr/images/event/txt_event01_05.gif" alt="대상" /></strong>
                                 <p><c:if test="${result.evntSubj == 'E1'}">
                                <able:hmcCodeTag type="codeNm" gCd="EVNTUBJ" comCd="E1"/>
                                </c:if>
                                <c:if test="${result.evntSubj == 'E2'}">
                                <able:hmcCodeTag type="codeNm" gCd="EVNTUBJ" comCd="E2"/>
                                </c:if></p>
							</li>
						</ul> 
                           <c:if test="${result.st == 'P'}">
                                <c:if test="${now0 gt now2}" > 
                                    <img src="/kr/images/common/button/btn_winner_ing.gif" alt="당첨자 선정중" class="winner-btn" />
                                </c:if> 
                            </c:if>
                            <c:if test="${result.st == 'S'}">
                                <a href="javascript:openLayer1('${result.evntMnSn}');"><img src="/kr/images/common/button/btn_winner_view.gif" alt="당첨자 보기" class="winner-btn" /></a>
                            </c:if>
                    </div>
                    </c:if>
                    </c:forEach>                    
                                       
				</div>
				<a href="<c:url value="/mpg/mpgEvntInfoView.do"/>"><img src="/kr/images/common/button/btn_more.gif" alt="더보기" class="more" /></a>
			</div>
			<div class="summary-contents-wrap subsection">
				<h5><img src="/kr/images/title/h5_global_menu03_01_05.gif" alt="Q&amp;A" /></h5>
				<div class="boardlist-wrap">
					<table summary="번호, 신청내용, 신청일자, 상태">
					<caption>상담신청내역</caption>
					<colgroup>
						<col width="10%" />
						<col width="25%" />
						<col />
						<col width="20%" />
						<col width="15%" />
					</colgroup>
					<thead>
					<tr>
						<th scope="col">NO</th>
						<th scope="col">카테고리</th>
						<th scope="col">제목</th>
						<th scope="col">등록일자</th>
						<th scope="col">상태</th>
					</tr>
					</thead>
					<tbody>
                    <c:if test="${empty qaList }">
                        <tr><td colspan="5">
                                                                       상담 이력이 없습니다.
                        </td></tr>
                    </c:if>

                            
                        <c:forEach var="result" items="${ qaList }" varStatus="status">
                          <c:if test ='${status.index lt 2  }' >
    
    
    					<tr>
                            <td class="center"><c:out value="${result.rnum}"></c:out></td>
                            <td class="center"><c:out value="${result.qaCategory }"></c:out></td>
                            <td class="center"><a href="javascript:qaDetailView('${result.qaSn}')"><c:out value="${result.titl}"></c:out></a></td>
                            <td class="center"><c:out value="${ result.rgstDtm }"></c:out></td>
                            <td class="center"><c:out value="${result.trtmStNm }"></c:out></td>
    					</tr>
                        
                        </c:if>
                        
                        </c:forEach>                       

                    
  
					</tbody>
					</table>
				</div>
				<a href="<c:url value="/mpg/QAListPaging.do"/>"><img src="/kr/images/common/button/btn_more.gif" alt="더보기" class="more" /></a>
			</div>
            </form>
		</div>
	</div>
	<hr />
    <%@ include file="/WEB-INF/jsp/com/include/footer.jspf" %>